﻿<UserControl x:Class="MOCSoftware.Utilities.PortInspector.View.HostListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Properties="clr-namespace:MOCSoftware.Utilities.PortInspector.Properties" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\\ApplicationResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="29" />
            <RowDefinition Height="52" />
            <RowDefinition Height="29" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>
        <Button Name="btnInspect" Grid.Row="0" Grid.ColumnSpan="2" Content="{x:Static Properties:Resources.HostListView_InspectButton}" Height="25" Margin="2,2,2,2" VerticalAlignment="Top" HorizontalAlignment="Stretch" IsEnabled="{Binding Path=AllHostsValid}" Visibility="{Binding StartButtonVisibility}" Command="{Binding InitiateScanning}" />
        <Button Name="btnCancelScanning" Grid.Row="0" Grid.ColumnSpan="2" Content="{x:Static Properties:Resources.HostListView_CancelButton}" Height="25" Margin="2,2,2,2" VerticalAlignment="Top" HorizontalAlignment="Stretch" Visibility="{Binding StopButtonVisibility}" IsEnabled="{Binding Path=AbortEnabled}" Command="{Binding AbortScanning}" />
        <Label Grid.Row="1" Grid.ColumnSpan="2" Content="{x:Static Properties:Resources.HostListView_HostAddLabel}" Target="{Binding ElementName=txtHostName}" />
        <TextBox Grid.Row="1" Name="txtHostName" MaxLength="255" Style="{StaticResource InputControlStyle}" Text="{Binding Path=HostName,Mode=OneWayToSource,UpdateSourceTrigger=Explicit}" />
        <Button Name="btnAddHost" Grid.Row="1" Grid.Column="1" Content="{x:Static Properties:Resources.HostListView_HostAddButton}" Height="25" Margin="2,25,2,2" VerticalAlignment="Top" Click="btnAddHost_Click">
            <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="IsEnabled" Value="false" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=txtHostName,Path=Text,Converter={StaticResource NullToBool}}" Value="false">
                            <Setter Property="IsEnabled" Value="true" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
        <Button Name="btnRemoveHost" Content="{x:Static Properties:Resources.HostListView_RemoveHost}" Grid.Row="2" Grid.Column="0" Margin="2,2,2,2" Height="25" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding Path=RemoveHostCommand}" IsEnabled="{Binding HostIsSelected}" Grid.RowSpan="2" />
        <Button Name="btnAddMany" Content="{x:Static Properties:Resources.HostListView_AddMany}" Grid.Row="2" Grid.Column="1" Margin="2,2,2,2" Height="25" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding AddHostListCommand}" />
        <Label Grid.Row="3" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,0,0,0" Target="{Binding ElementName=lstHosts}" Content="{x:Static Properties:Resources.PortListView_HostLabel}" />
        <ListBox Name="lstHosts" Grid.Row="3" Grid.ColumnSpan="2" Margin="5,25,5,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemTemplate="{StaticResource HostList}" ItemsSource="{Binding Path=HostList}" SelectedItem="{Binding Path=SelectedHost,Mode=TwoWay}">
            <ListBox.ContextMenu>
                <ContextMenu ItemsSource="{Binding MenuItems}" ItemTemplate="{StaticResource ContextMenuTemplate}">
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
    </Grid>
</UserControl>
